package com.aspose.cells;

import java.util.ArrayList;
import java.util.Iterator;

public class PageSetup {
   private static com.aspose.cells.b.a.g.a.ze g = null;
   private Worksheet h;
   private Object i;
   private boolean j;
   private boolean k;
   private boolean l;
   private boolean m;
   private double n = 0.5D;
   private double o = 0.5D;
   private byte[] p = null;
   private double q = 0.75D;
   private double r = 0.75D;
   private double s = 1.0D;
   private double t = 1.0D;
   private int u = 1;
   private int v = 1;
   private int w = 1;
   private boolean x = true;
   private int y = 0;
   private int z = 1;
   private boolean A = false;
   private int B = 1;
   private int C = 2;
   private boolean D;
   private boolean E;
   private int F = 100;
   private int G = 0;
   private int H = 300;
   private int I = 300;
   private int J = 1;
   String[] a = new String[3];
   String[] b = new String[3];
   String[] c;
   String[] d;
   String[] e;
   String[] f;
   private byte K = 4;
   private ShapeCollection L;
   private short M = 127;

   private static com.aspose.cells.b.a.g.a.ze n() {
      if (g == null) {
         g = new com.aspose.cells.b.a.g.a.ze("(?<!&)(&[lLcCrR])");
      }

      return g;
   }

   void a(PageSetup var1, CopyOptions var2) {
      this.j = var1.j;
      this.t = var1.t;
      this.k = var1.k;
      this.l = var1.l;
      this.m = var1.m;
      this.u = var1.u;
      this.v = var1.v;
      this.w = var1.w;
      this.x = var1.x;
      this.o = var1.o;
      this.n = var1.n;
      this.q = var1.q;
      this.y = var1.y;
      this.z = var1.z;
      this.A = var1.A;
      this.G = var1.G;
      if (var1.p != null && var1.p.length > 0) {
         this.p = new byte[var1.p.length];
         System.arraycopy(var1.p, 0, this.p, 0, var1.p.length);
      }

      this.B = var1.B;
      this.C = var1.C;
      this.E = var1.E;
      this.D = var1.D;
      this.r = var1.r;
      this.s = var1.s;
      this.F = var1.F;
      this.K = var1.K;
      int var3;
      if (var1.a != null) {
         this.a = new String[3];

         for(var3 = 0; var3 < 3; ++var3) {
            this.a[var3] = var1.a[var3];
         }
      }

      if (var1.b != null) {
         this.b = new String[3];

         for(var3 = 0; var3 < 3; ++var3) {
            this.b[var3] = var1.b[var3];
         }
      }

      this.L = null;
      if (var1.L != null && var1.L.getCount() != 0) {
         Iterator var7 = var1.L.iterator();

         while(var7.hasNext()) {
            Shape var4 = (Shape)var7.next();
            Picture var5 = (Picture)var4;
            Picture var6 = new Picture(this.i());
            var6.a(var5, var2);
            this.i().c(var6);
         }
      }

      this.H = var1.H;
      this.I = var1.I;
      this.M = var1.M;
   }

   private boolean o() {
      return this.i instanceof Worksheet;
   }

   PageSetup(Worksheet sheet, Object parent) {
      this.h = sheet;
      this.i = parent;
      this.G = 9;
   }

   public String getPrintArea() {
      Range[] var1 = this.b(false);
      if (var1 != null) {
         WorkbookSettings var2 = this.h.c().n().getSettings();
         int var3 = var2.k();
         int var4 = var2.l();
         StringBuilder var5 = new StringBuilder();

         for(int var6 = 0; var6 < var1.length; ++var6) {
            var5.append(var1[var6].a(var3, var4, false));
            if (var6 != var1.length - 1) {
               var5.append(',');
            }
         }

         return com.aspose.cells.b.a.zr.a(var5);
      } else {
         return null;
      }
   }

   public void setPrintArea(String value) {
      if (this.o()) {
         this.h.c().getNames().a(this.h.getIndex(), "PRINT_AREA", value, true);
      }

   }

   public String getPrintTitleColumns() {
      Range[] var1 = this.b(true);
      if (var1 != null && var1[1] != null) {
         WorkbookSettings var2 = this.h.c().n().getSettings();
         int var3 = var2.k();
         int var4 = var2.l();
         return var1[1].a(var3, var4, true);
      } else {
         return null;
      }
   }

   public void setPrintTitleColumns(String value) {
      if (this.o()) {
         if (!zbpt.a(value) && value.indexOf(":") == -1) {
            throw new CellsException(6, "Invalid print title.");
         } else {
            String var2 = this.getPrintTitleRows();
            String var4 = null;
            if (var2 != null && !"".equals(var2)) {
               var4 = var2;
               if (value != null && !"".equals(value)) {
                  var4 = var2 + "," + value;
               }
            } else {
               var4 = value;
            }

            this.h.c().getNames().a(this.h.getIndex(), "PRINT_TITLES", var4, true);
         }
      }
   }

   public String getPrintTitleRows() {
      Range[] var1 = this.b(true);
      if (var1 != null && var1[0] != null) {
         WorkbookSettings var2 = this.h.c().n().getSettings();
         int var3 = var2.k();
         int var4 = var2.l();
         return var1[0].a(var3, var4, true);
      } else {
         return null;
      }
   }

   public void setPrintTitleRows(String value) {
      if (this.o()) {
         if (!zbpt.a(value) && value.indexOf(":") == -1) {
            throw new CellsException(6, "Invalid print title.");
         } else {
            String var3 = this.getPrintTitleColumns();
            String var4 = null;
            if (value != null && !"".equals(value)) {
               var4 = value;
               if (var3 != null && !"".equals(var3)) {
                  var4 = value + "," + var3;
               }
            } else {
               var4 = var3;
            }

            this.h.c().getNames().a(this.h.getIndex(), "PRINT_TITLES", var4, true);
         }
      }
   }

   void a(String var1) {
      if (this.o()) {
         this.h.c().getNames().a(this.h.getIndex(), "PRINT_TITLES", var1, true);
      }

   }

   boolean a(boolean var1) {
      if (!this.o()) {
         return false;
      } else {
         return this.h.c().getNames().a(var1 ? "PRINT_TITLES" : "PRINT_AREA", this.h.getIndex(), false) > 0;
      }
   }

   Range[] b(boolean var1) {
      if (!this.o()) {
         return null;
      } else {
         WorkbookSettings var2 = this.h.c().n().getSettings();
         int var3 = var2.k();
         int var4 = var2.l();
         Range[] var5 = this.h.c().getNames().d(this.h.getIndex(), var1 ? "PRINT_TITLES" : "PRINT_AREA");
         if (var1 && var5 != null) {
            if (var5.length == 1) {
               Range[] var7 = new Range[2];
               if (var5[0].a(var4)) {
                  var7[0] = var5[0];
               } else {
                  if (!var5[0].b(var3)) {
                     return null;
                  }

                  var7[1] = var5[0];
               }

               return var7;
            }

            if (var5.length == 2 && !var5[0].a(var4)) {
               Range var6 = var5[0];
               var5[0] = var5[1];
               var5[1] = var6;
            }
         }

         return var5;
      }
   }

   public boolean getBlackAndWhite() {
      return this.j;
   }

   public void setBlackAndWhite(boolean value) {
      this.j = value;
   }

   public boolean getCenterHorizontally() {
      return this.k;
   }

   public void setCenterHorizontally(boolean value) {
      this.k = value;
   }

   public boolean getCenterVertically() {
      return this.l;
   }

   public void setCenterVertically(boolean value) {
      this.l = value;
   }

   /** @deprecated */
   public boolean getDraft() {
      return this.m;
   }

   /** @deprecated */
   public void setDraft(boolean value) {
      this.m = value;
   }

   public boolean getPrintDraft() {
      return this.m;
   }

   public void setPrintDraft(boolean value) {
      this.m = value;
   }

   public double getFooterMargin() {
      return this.n * 2.54D;
   }

   public void setFooterMargin(double value) {
      this.n = value / 2.54D;
   }

   public double getFooterMarginInch() {
      return this.n;
   }

   public void setFooterMarginInch(double value) {
      this.n = value;
   }

   public double getHeaderMargin() {
      return this.o * 2.54D;
   }

   public void setHeaderMargin(double value) {
      this.o = value / 2.54D;
   }

   public double getHeaderMarginInch() {
      return this.o;
   }

   public void setHeaderMarginInch(double value) {
      this.o = value;
   }

   byte[] a() {
      return this.p;
   }

   void a(byte[] var1) {
      this.p = var1;
   }

   public double getLeftMargin() {
      return this.q * 2.54D;
   }

   public void setLeftMargin(double value) {
      this.q = value / 2.54D;
   }

   public double getLeftMarginInch() {
      return this.q;
   }

   public void setLeftMarginInch(double value) {
      this.q = value;
   }

   public double getRightMargin() {
      return this.r * 2.54D;
   }

   public void setRightMargin(double value) {
      this.r = value / 2.54D;
   }

   public double getRightMarginInch() {
      return this.r;
   }

   public void setRightMarginInch(double value) {
      this.r = value;
   }

   public double getTopMargin() {
      return this.s * 2.54D;
   }

   public void setTopMargin(double value) {
      this.s = value / 2.54D;
   }

   public double getTopMarginInch() {
      return this.s;
   }

   public void setTopMarginInch(double value) {
      this.s = value;
   }

   public double getBottomMargin() {
      return this.t * 2.54D;
   }

   public void setBottomMargin(double value) {
      this.t = value / 2.54D;
   }

   public double getBottomMarginInch() {
      return this.t;
   }

   public void setBottomMarginInch(double value) {
      this.t = value;
   }

   public int getFirstPageNumber() {
      return this.u;
   }

   public void setFirstPageNumber(int value) {
      this.u = value;
      this.setAutoFirstPageNumber(false);
   }

   public int getFitToPagesTall() {
      return this.v;
   }

   public void setFitToPagesTall(int value) {
      if (value >= 0 && value <= 65535) {
         this.e(false);
         this.v = value;
         this.x = false;
      }

   }

   void a(int var1) {
      this.v = var1;
   }

   void b(int var1) {
      this.w = var1;
   }

   public int getFitToPagesWide() {
      return this.w;
   }

   public void setFitToPagesWide(int value) {
      if (value >= 0 && value <= 65535) {
         this.e(false);
         this.w = value;
         this.x = false;
      }

   }

   public boolean isPercentScale() {
      return this.x;
   }

   public void setPercentScale(boolean value) {
      this.x = value;
   }

   public int getOrder() {
      return this.y;
   }

   public void setOrder(int value) {
      this.y = value;
   }

   public int getPaperSize() {
      return (this.G <= 0 || this.G > 118) && (this.G < 300 || this.G > 301) ? 9 : this.G;
   }

   public void setPaperSize(int value) {
      this.d(false);
      this.G = value;
   }

   void b() {
      this.z = 0;
      this.A = false;
   }

   int c() {
      return this.G;
   }

   void c(int var1) {
      this.G = var1;
   }

   public int getOrientation() {
      return this.z;
   }

   public void setOrientation(int value) {
      this.h(false);
      this.z = value;
      this.A = false;
   }

   public int getPrintComments() {
      return this.B;
   }

   public void setPrintComments(int value) {
      this.B = value;
   }

   public int getPrintErrors() {
      return this.C;
   }

   public void setPrintErrors(int value) {
      this.C = value;
   }

   public boolean getPrintHeadings() {
      return this.D;
   }

   public void setPrintHeadings(boolean value) {
      this.D = value;
   }

   public boolean getPrintGridlines() {
      return this.E;
   }

   public void setPrintGridlines(boolean value) {
      this.E = value;
   }

   public int getZoom() {
      return this.F;
   }

   public void setZoom(int value) {
      if (value >= 10 && value <= 400) {
         this.e(false);
         this.F = value;
         this.x = true;
      } else {
         throw new IllegalArgumentException("Zoom value should be between 10 and 400.");
      }
   }

   void d(int var1) {
      this.F = var1;
   }

   public boolean isAutoFirstPageNumber() {
      return (this.M & 64) != 0;
   }

   public void setAutoFirstPageNumber(boolean value) {
      if (value) {
         this.M = (short)(this.M | 64);
      } else {
         this.M = (short)(this.M & -65);
      }

   }

   void b(byte[] var1) {
      if (var1.length >= 34) {
         this.G = com.aspose.cells.b.a.zc.e(var1, 0) & '\uffff';
         this.u = com.aspose.cells.b.a.zc.b(var1, 4);
         this.w = com.aspose.cells.b.a.zc.e(var1, 6) & '\uffff';
         this.v = com.aspose.cells.b.a.zc.e(var1, 8) & '\uffff';
         int var2 = var1[10] & 255 & 1;
         if (var2 == 0) {
            this.y = 0;
         } else {
            this.y = 1;
         }

         var2 = var1[10] & 255 & 2;
         if (var2 == 0) {
            this.z = 0;
         } else {
            this.z = 1;
         }

         var2 = var1[10] & 255 & 4;
         int var3;
         if (var2 != 0) {
            this.c(false);
            if (this.h != null && this.h.getType() != 2) {
               this.z = 1;
            }
         } else {
            this.c(true);
            var3 = com.aspose.cells.b.a.zc.e(var1, 2);
            if ((var3 & '\uffff') >= 10 && (var3 & '\uffff') <= 400) {
               this.F = var3 & '\uffff';
            }
         }

         var2 = var1[10] & 255 & 8;
         if (var2 == 0) {
            this.j = false;
         } else {
            this.j = true;
         }

         var2 = var1[10] & 255 & 16;
         if (var2 == 0) {
            this.m = false;
         } else {
            this.m = true;
         }

         var2 = var1[10] & 255 & 128;
         this.setAutoFirstPageNumber(var2 == 0);
         this.A = (var1[10] & 255 & 64) != 0;
         if (this.A) {
            this.z = 1;
         }

         var3 = var1[10] & 255 & 32;
         var2 = var1[11] & 255 & 2;
         if (var3 == 0) {
            this.B = 1;
         } else if (var2 == 0) {
            this.B = 0;
         } else {
            this.B = 2;
         }

         var2 = (var1[11] & 255 & 12) >> 2;
         switch(var2) {
         case 0:
            this.C = 2;
            break;
         case 1:
            this.C = 0;
            break;
         case 2:
            this.C = 1;
            break;
         case 3:
            this.C = 3;
         }

         short var4 = com.aspose.cells.b.a.zc.b(var1, 12);
         if (var4 > 0) {
            this.H = var4;
         }

         var4 = com.aspose.cells.b.a.zc.b(var1, 14);
         if (var4 > 0) {
            this.I = var4;
         }

         this.o = com.aspose.cells.b.a.zc.f(var1, 16);
         this.n = com.aspose.cells.b.a.zc.f(var1, 24);
         if (this.e()) {
            int var5 = com.aspose.cells.b.a.zc.e(var1, 32) & '\uffff';
            if (var5 > 0) {
               this.J = var5;
            }
         }

      }
   }

   byte[] d() {
      byte[] var1 = new byte[34];
      int var2 = this.G;
      System.arraycopy(com.aspose.cells.b.a.zc.a(var2), 0, var1, 0, 2);
      System.arraycopy(com.aspose.cells.b.a.zc.a(this.F), 0, var1, 2, 2);
      System.arraycopy(com.aspose.cells.b.a.zc.a(this.u), 0, var1, 4, 2);
      System.arraycopy(com.aspose.cells.b.a.zc.a(this.w), 0, var1, 6, 2);
      System.arraycopy(com.aspose.cells.b.a.zc.a(this.v), 0, var1, 8, 2);
      if (this.y == 1) {
         var1[10] = (byte)(var1[10] | 1);
      }

      if (this.z == 1) {
         var1[10] = (byte)(var1[10] | 2);
      }

      if (!this.e()) {
         var1[10] = (byte)(var1[10] | 4);
      }

      if (this.j) {
         var1[10] = (byte)(var1[10] | 8);
      }

      if (this.m) {
         var1[10] = (byte)(var1[10] | 16);
      }

      if (this.B != 1) {
         var1[10] = (byte)(var1[10] | 32);
      }

      if (this.A) {
         var1[10] = (byte)(var1[10] | 64);
      }

      if (!this.isAutoFirstPageNumber() || this.u != 1) {
         var1[10] = (byte)(var1[10] | 128);
      }

      if (this.B == 2) {
         var1[11] = (byte)(var1[11] | 2);
      }

      switch(this.C) {
      case 0:
         var1[11] = (byte)(var1[11] | 4);
         break;
      case 1:
         var1[11] = (byte)(var1[11] | 8);
      case 2:
      default:
         break;
      case 3:
         var1[11] = (byte)(var1[11] | 12);
      }

      System.arraycopy(com.aspose.cells.b.a.zc.a(this.H), 0, var1, 12, 2);
      System.arraycopy(com.aspose.cells.b.a.zc.a(this.I), 0, var1, 14, 2);
      System.arraycopy(com.aspose.cells.b.a.zc.a(this.o), 0, var1, 16, 8);
      System.arraycopy(com.aspose.cells.b.a.zc.a(this.n), 0, var1, 24, 8);
      System.arraycopy(com.aspose.cells.b.a.zc.a(this.J), 0, var1, 32, 2);
      return var1;
   }

   boolean e() {
      return (this.M & 63) != 63;
   }

   void c(boolean var1) {
      if (var1) {
         this.M = (short)(this.M & -64);
      } else {
         this.M = (short)(this.M | 63);
      }

   }

   int f() {
      return this.H;
   }

   void e(int var1) {
      this.H = var1;
      if (this.h != null) {
         this.h.l = null;
      }

   }

   int g() {
      return this.I;
   }

   void f(int var1) {
      this.I = var1;
      if (this.h != null) {
         this.h.l = null;
      }

   }

   public int getPrintQuality() {
      return this.H;
   }

   public void setPrintQuality(int value) {
      if (value > 0) {
         this.H = value;
         this.I = value;
         this.f(false);
         this.g(false);
         if (this.h != null) {
            this.h.l = null;
         }
      }

   }

   public int getPrintCopies() {
      return this.J;
   }

   public void setPrintCopies(int value) {
      this.c(true);
      this.J = value;
   }

   public void clearHeaderFooter() {
      this.a = new String[3];
      this.b = new String[3];
   }

   public String getHeader(int section) {
      if (section >= 0 && section <= 2) {
         return this.a == null ? null : this.a[section];
      } else {
         throw new IllegalArgumentException("The section number is out of range.");
      }
   }

   public HeaderFooterCommand[] getCommands(String headerFooterScript) {
      if (headerFooterScript != null && headerFooterScript.length() != 0) {
         int var2 = 0;

         while(var2 + 2 < headerFooterScript.length()) {
            if (headerFooterScript.charAt(var2) == '&') {
               boolean var3 = false;
               switch(headerFooterScript.charAt(var2 + 1)) {
               case 'C':
               case 'L':
               case 'R':
               case 'c':
               case 'l':
               case 'r':
                  var3 = true;
                  var2 += 2;
               }

               if (!var3) {
                  break;
               }
            }
         }

         if (var2 != 0) {
            headerFooterScript = headerFooterScript.substring(var2);
         }

         if (headerFooterScript.length() == 0) {
            return null;
         } else {
            ArrayList var7 = HeaderFooterCommand.a(this.h.c().n(), headerFooterScript);
            HeaderFooterCommand[] var4 = new HeaderFooterCommand[var7.size()];
            Font var5 = new Font(this.h.c(), (Object)null, false);
            var5.c(this.h.c().G());

            for(int var6 = 0; var6 < var7.size(); ++var6) {
               var4[var6] = (HeaderFooterCommand)var7.get(var6);
               if (var4[var6].getFont() == null && var4[var6].getType() != 8) {
                  var4[var6].a = var5;
               }
            }

            return var4;
         }
      } else {
         return null;
      }
   }

   String g(int var1) {
      if (var1 >= 0 && var1 <= 2) {
         if (this.a == null) {
            return null;
         } else {
            String var2 = this.a[var1];
            if (var2 != null) {
               var2 = n().b(var2, "");
            }

            return var2;
         }
      } else {
         throw new IllegalArgumentException("The section number is out of range.");
      }
   }

   public String getFooter(int section) {
      if (section >= 0 && section <= 2) {
         return this.b == null ? null : this.b[section];
      } else {
         throw new IllegalArgumentException("The section number is out of range.");
      }
   }

   String h(int var1) {
      if (var1 >= 0 && var1 <= 2) {
         if (this.b == null) {
            return null;
         } else {
            String var2 = this.b[var1];
            if (var2 != null) {
               var2 = n().b(var2, "");
            }

            return var2;
         }
      } else {
         throw new IllegalArgumentException("The section number is out of range.");
      }
   }

   public void setHeader(int section, String headerScript) {
      a(this.a, section, headerScript);
   }

   public void setFooter(int section, String footerScript) {
      a(this.b, section, footerScript);
   }

   static void a(String[] var0, int var1, String var2) {
      if (var1 >= 0 && var1 <= 2) {
         if (var2 != null && !"".equals(var2)) {
            var2 = n().b(var2, "");
            switch(var1) {
            case 0:
               var0[0] = var2;
               break;
            case 1:
               var0[1] = var2;
               break;
            case 2:
               var0[2] = var2;
            }

         } else {
            var0[var1] = null;
         }
      } else {
         throw new IllegalArgumentException("The section number is out of range.");
      }
   }

   byte h() {
      return this.K;
   }

   void a(byte var1) {
      this.K = var1;
   }

   public void setEvenHeader(int section, String headerScript) {
      if (this.c == null) {
         this.c = new String[3];
      }

      a(this.c, section, headerScript);
   }

   String i(int var1) {
      if (var1 >= 0 && var1 <= 2) {
         if (this.c == null) {
            return null;
         } else {
            String var2 = this.c[var1];
            if (var2 != null) {
               var2 = n().b(var2, "");
            }

            return var2;
         }
      } else {
         throw new IllegalArgumentException("The section number is out of range.");
      }
   }

   public String getEvenHeader(int section) {
      if (section >= 0 && section <= 2) {
         return this.c == null ? null : this.c[section];
      } else {
         throw new IllegalArgumentException("The section number is out of range.");
      }
   }

   String j(int var1) {
      if (var1 >= 0 && var1 <= 2) {
         if (this.d == null) {
            return null;
         } else {
            String var2 = this.d[var1];
            if (var2 != null) {
               var2 = n().b(var2, "");
            }

            return var2;
         }
      } else {
         throw new IllegalArgumentException("The section number is out of range.");
      }
   }

   public void setEvenFooter(int section, String footerScript) {
      if (this.d == null) {
         this.d = new String[3];
      }

      a(this.d, section, footerScript);
   }

   public String getEvenFooter(int section) {
      if (section >= 0 && section <= 2) {
         return this.d == null ? null : this.d[section];
      } else {
         throw new IllegalArgumentException("The section number is out of range.");
      }
   }

   private static String a(String[] var0) {
      if (var0 == null) {
         return "";
      } else {
         StringBuilder var1 = new StringBuilder();
         if (var0[0] != null && var0[0].length() != 0) {
            if (!var0[0].startsWith("&L")) {
               var1.append("&L");
            }

            var1.append(var0[0]);
         }

         if (var0[1] != null && var0[1].length() != 0) {
            if (!var0[1].startsWith("&C")) {
               var1.append("&C");
            }

            var1.append(var0[1]);
         }

         if (var0[2] != null && var0[2].length() != 0) {
            if (!var0[2].startsWith("&R")) {
               var1.append("&R");
            }

            var1.append(var0[2]);
         }

         return com.aspose.cells.b.a.zr.a(var1);
      }
   }

   String a(boolean var1, int var2) {
      if (var1) {
         switch(var2) {
         case 0:
            return a(this.c);
         case 1:
            return a(this.a);
         case 2:
            return a(this.f);
         }
      } else {
         switch(var2) {
         case 0:
            return a(this.d);
         case 1:
            return a(this.b);
         case 2:
            return a(this.e);
         }
      }

      return "";
   }

   public void setFirstPageHeader(int section, String headerScript) {
      if (this.f == null) {
         this.f = new String[3];
      }

      a(this.f, section, headerScript);
   }

   public String getFirstPageHeader(int section) {
      if (section >= 0 && section <= 2) {
         return this.f == null ? null : this.f[section];
      } else {
         throw new IllegalArgumentException("The section number is out of range.");
      }
   }

   public void setFirstPageFooter(int section, String footerScript) {
      if (this.e == null) {
         this.e = new String[3];
      }

      a(this.e, section, footerScript);
   }

   String k(int var1) {
      if (var1 >= 0 && var1 <= 2) {
         if (this.e == null) {
            return null;
         } else {
            String var2 = this.e[var1];
            if (var2 != null) {
               var2 = n().b(var2, "");
            }

            return var2;
         }
      } else {
         throw new IllegalArgumentException("The section number is out of range.");
      }
   }

   String l(int var1) {
      if (var1 >= 0 && var1 <= 2) {
         if (this.f == null) {
            return null;
         } else {
            String var2 = this.f[var1];
            if (var2 != null) {
               var2 = n().b(var2, "");
            }

            return var2;
         }
      } else {
         throw new IllegalArgumentException("The section number is out of range.");
      }
   }

   public String getFirstPageFooter(int section) {
      if (section >= 0 && section <= 2) {
         return this.e == null ? null : this.e[section];
      } else {
         throw new IllegalArgumentException("The section number is out of range.");
      }
   }

   public boolean isHFDiffOddEven() {
      return (this.K & 255 & 1) != 0;
   }

   public void setHFDiffOddEven(boolean value) {
      if (value) {
         this.K = (byte)(this.K | 1);
      } else {
         this.K &= -2;
      }

   }

   public boolean isHFDiffFirst() {
      return (this.K & 255 & 2) != 0;
   }

   public void setHFDiffFirst(boolean value) {
      if (value) {
         this.K = (byte)(this.K | 2);
      } else {
         this.K &= -3;
      }

   }

   public boolean isHFScaleWithDoc() {
      return (this.K & 255 & 4) != 0;
   }

   public void setHFScaleWithDoc(boolean value) {
      if (value) {
         this.K = (byte)(this.K | 4);
      } else {
         this.K &= -5;
      }

   }

   public boolean isHFAlignMargins() {
      return (this.K & 255 & 8) != 0;
   }

   public void setHFAlignMargins(boolean value) {
      if (value) {
         this.K = (byte)(this.K | 8);
      } else {
         this.K &= -9;
      }

   }

   static void a(String var0, String[] var1) {
      int var2 = -1;
      int var3 = 0;

      for(int var4 = 0; var4 < var0.length(); ++var4) {
         if (var0.charAt(var4) == '&' && var4 + 1 < var0.length()) {
            boolean var5 = true;
            byte var6;
            switch(var0.charAt(var4 + 1)) {
            case '&':
               ++var4;
               continue;
            case 'C':
            case 'c':
               var6 = 1;
               break;
            case 'L':
            case 'l':
               var6 = 0;
               break;
            case 'R':
            case 'r':
               var6 = 2;
               break;
            default:
               continue;
            }

            if (var4 - var3 > 0) {
               if (var3 == 0 && var2 == -1) {
                  var2 = var6 - 1 < 0 ? 0 : var6 - 1;
               }

               a(var1, var2, var0.substring(var3, var3 + (var4 - var3)));
            }

            var2 = var6;
            var3 = var4;
         }
      }

      if (var3 < var0.length()) {
         a(var1, var2 == -1 ? 1 : var2, var0.substring(var3));
      }

   }

   void c(byte[] var1) {
      if (var1.length > 2) {
         String var2;
         if (var1[2] == 0) {
            byte[] var3 = new byte[(var1.length - 3) * 2];

            for(int var4 = 0; var4 < var3.length / 2; ++var4) {
               var3[2 * var4] = var1[3 + var4];
            }

            var2 = Encoding.getUnicode().a(var3);
         } else {
            var2 = Encoding.getUnicode().a(var1, 3, var1.length - 3);
         }

         if (this.a == null) {
            this.a = new String[3];
         }

         a(var2, this.a);
      }
   }

   void d(byte[] var1) {
      if (var1.length > 2) {
         if (this.b == null) {
            this.b = new String[3];
         }

         String var2;
         if (var1[2] == 0) {
            byte[] var3 = new byte[(var1.length - 3) * 2];

            for(int var4 = 0; var4 < var3.length / 2; ++var4) {
               var3[2 * var4] = var1[3 + var4];
            }

            var2 = Encoding.getUnicode().a(var3);
         } else {
            var2 = Encoding.getUnicode().a(var1, 3, var1.length - 3);
         }

         a(var2, this.b);
      }
   }

   ShapeCollection i() {
      if (this.L == null) {
         this.L = new ShapeCollection(this.h.c(), this.h, this.h.c().S(), this, -1);
      }

      return this.L;
   }

   void a(ShapeCollection var1) {
      this.L = var1;
   }

   ShapeCollection j() {
      return this.L;
   }

   static char m(int var0) {
      switch(var0) {
      case 0:
         return 'L';
      case 1:
         return 'C';
      case 2:
         return 'R';
      default:
         throw new IllegalArgumentException("The section number is out of range.");
      }
   }

   public Picture setHeaderPicture(int section, byte[] headerPicture) {
      String var3 = m(section) + "H";
      int var4 = this.b(var3);
      if (var4 != -1) {
         this.i().c(var4);
      }

      return this.a(var3, headerPicture);
   }

   public Picture setFooterPicture(int section, byte[] footerPicture) {
      String var3 = m(section) + "F";
      int var4 = this.b(var3);
      if (var4 != -1) {
         this.i().c(var4);
      }

      return this.a(var3, footerPicture);
   }

   public Picture setPicture(boolean isFirst, boolean isEven, boolean isHeader, int section, byte[] imageData) {
      String var6 = this.a(isFirst, isEven, isHeader, section);
      int var7 = this.b(var6);
      if (var7 != -1) {
         this.i().c(var7);
      }

      return this.a(var6, imageData);
   }

   public Picture getPicture(boolean isHeader, int section) {
      String var3 = "" + m(section);
      if (isHeader) {
         var3 = var3 + "H";
      } else {
         var3 = var3 + "F";
      }

      int var4 = this.b(var3);
      return var4 != -1 ? (Picture)this.i().get(var4) : null;
   }

   public Picture getPicture(boolean isFirst, boolean isEven, boolean isHeader, int section) {
      String var5 = this.a(isFirst, isEven, isHeader, section);
      int var6 = this.b(var5);
      return var6 != -1 ? (Picture)this.i().get(var6) : null;
   }

   Picture a(String var1, byte[] var2) {
      Picture var3 = new Picture(this.i());
      var3.a(this.i().a((Shape)var3, (byte[])var2));
      var3.a((zanr)null);
      var3.N().c().a(50048, 2, var1);
      zcb var4 = var3.a();
      int var5 = 0;
      int var6 = 0;
      if (var4 != null) {
         var5 = var4.k();
         var6 = var4.l();
      }

      var3.a(0, false, 0, 0, var5, var6);
      return var3;
   }

   private String a(boolean var1, boolean var2, boolean var3, int var4) {
      StringBuilder var5 = new StringBuilder();
      var5.append(m(var4));
      if (var3) {
         var5.append("H");
      } else {
         var5.append("F");
      }

      if (var1) {
         var5.append("FIRST");
      } else if (var2) {
         var5.append("EVEN");
      }

      return com.aspose.cells.b.a.zr.a(var5);
   }

   int b(String var1) {
      if (this.L != null && this.L.getCount() != 0) {
         int var2 = 0;

         for(Iterator var3 = this.L.iterator(); var3.hasNext(); ++var2) {
            Shape var4 = (Shape)var3.next();
            String var5 = var4.N().c().e(50048);
            if (var5 == null || "".equals(var5)) {
               var5 = var4.N().c().e(33664);
            }

            if (com.aspose.cells.b.a.zv.b(var5, var1)) {
               return var2;
            }
         }

         return -1;
      } else {
         return -1;
      }
   }

   public boolean isAutomaticPaperSize() {
      return (this.M & 1) != 0;
   }

   boolean k() {
      return (this.M & 1) != 0;
   }

   void d(boolean var1) {
      if (var1) {
         this.M = (short)(this.M | 1);
      } else {
         this.M = (short)(this.M & -2);
      }

   }

   void e(boolean var1) {
      if (var1) {
         this.M = (short)(this.M | 2);
      } else {
         this.M = (short)(this.M & -3);
      }

   }

   boolean l() {
      return (this.M & 4) != 0;
   }

   void f(boolean var1) {
      if (var1) {
         this.M = (short)(this.M | 4);
      } else {
         this.M = (short)(this.M & -5);
      }

   }

   boolean m() {
      return (this.M & 8) != 0;
   }

   void g(boolean var1) {
      if (var1) {
         this.M = (short)(this.M | 8);
      } else {
         this.M = (short)(this.M & -9);
      }

   }

   void h(boolean var1) {
      if (var1) {
         this.M = (short)(this.M | 32);
      } else {
         this.M = (short)(this.M & -33);
      }

   }
}
